using UnityEngine;
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

public class TrackableBehaviour : MaxstAR.ITrackableBehaviour
{
    private Vector2 trackableSize = Vector2.zero;

    void Start()
    {
    }

    public override void OnTrackSuccess(Vector3 translation, Quaternion orientation, Vector2 size)
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }

        transform.position = translation;
        transform.rotation = orientation;
        trackableSize = size;
    }

    public override void OnTrackFail()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = false;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = false;
        }
    }
}
